package cz.zcu.fav.rat.managed.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;

@FacesConverter(value = "md5converver")
public class MD5Converter implements Converter
{
	private static final Logger logger = Logger.getLogger(MD5Converter.class);

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2)
	{
		return DigestUtils.md5Hex(arg2);
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2)
	{
		return String.valueOf(arg2);
	}

}
